<template>
	<view>

		<view class="page_content">
			<view class="LogoBox">
				<view class="Logo">
					<up-image :show-loading="true" :src="uni.$utils.getResourceUrl('image/Logo/Logo.png')"
						width="120rpx" height="120rpx" :radius="12"></up-image>
					<view class="text f-dc" style="letter-spacing: 6px;">
						<text style="color: #51d0d0;font-size: 28rpx;">汇创H6</text>
						<text>云平台</text>
					</view>
				</view>
			</view>

			<view class="FormBox">
				<up-form ref="baseFormRef" :model="formData" :rules="rules" labelPosition="left">
					<up-form-item prop="Business_Code">
						<view class="x-f" style="width: 100%;">
							<uni-icons fontFamily="CustomFontPlatform" color="#333"
								size="40rpx">{{uni.$utils.toUniCode('&#xe75f;')}}</uni-icons>

							<view class="iptView">
								<up-input placeholder="请输入企业代号" border="bottom" type="text"
									v-model="formData.Business_Code" :clearable="false" @blur="GetBusiness"></up-input>
							</view>
						</view>
					</up-form-item>

					<up-form-item name="Business">

						<view class="x-f" style="width: 100%;">
							<uni-icons fontFamily="CustomFontPlatform" color="#333"
								size="40rpx">{{uni.$utils.toUniCode('&#xe64b;')}}</uni-icons>

							<view class="iptView">
								<!-- <up-input placeholder="请选择账套" border="bottom" type="text" readonly
									v-model="formData.BusinessName" :clearable="false"
									suffixIcon="arrow-down"></up-input> -->

								<uni-data-select style="width: 100%;" mode="none" v-model="formData.Business"
									:localdata="BusinessList" :clear="false" @change="SelectBusiness"
									placeholder="请选择账套"></uni-data-select>
							</view>
						</view>

					</up-form-item>

					<up-form-item prop="UserAccount">
						<view class="x-f" style="width: 100%;">
							<uni-icons fontFamily="CustomFontPlatform" color="#333"
								size="40rpx">{{uni.$utils.toUniCode('&#xe649;')}}</uni-icons>

							<up-input placeholder="请输入账号" border="bottom" type="text" v-model="formData.UserAccount"
								:clearable="false"></up-input>
						</view>
					</up-form-item>

					<up-form-item prop="UserPwd">
						<view class="x-f" style="width: 100%;">
							<uni-icons fontFamily="CustomFontPlatform" color="#333"
								size="40rpx">{{uni.$utils.toUniCode('&#xe60c;')}}</uni-icons>

							<up-input placeholder="请输入密码" border="bottom" :password="true" type="password"
								v-model="formData.UserPwd" :clearable="false"></up-input>
						</view>
					</up-form-item>

					<up-form-item>
						<view class="x-bc" style="width: 100%;">
							<view class="x-f">
								<up-checkbox-group v-model="RemberCheck" placement="column" @change="checkboxChange">
									<up-checkbox activeColor="#51d0d0" label="记住密码" name="记住密码">
									</up-checkbox>
								</up-checkbox-group>

								<view @click="openWebInBrowser(1)" style="color: #51d0d0;margin-left: 10px;">用户协议</view>
								<view @click="openWebInBrowser(2)" style="color: #51d0d0;margin-left: 10px;">隐私政策</view>



							</view>
						</view>
					</up-form-item>

				</up-form>
			</view>

			<view class="BtnBox">
				<button class="LoginBtn" type="primary" :loading="loginConfig.isLoading"
					:disabled="loginConfig.isLoading" @click="LoginApp">
					<text class="Text">{{loginConfig.isLoading ? '正在登录...' :'登录'}}</text>
				</button>
			</view>

			<view class="BottomText f-dc">
				<!-- <text>浙ICP备2024083567号-5X</text> -->
				<text>—— ©汇智云创 技术支持 ——</text>
			</view>

		</view>
		<m-loading :text="loginConfig.loadingText" :value="loginConfig.showMLoading" :showClose="false"
			maskBackgroundColor="rgba(0,0,0,0.3)"></m-loading>
	</view>
</template>

<script setup lang="ts">
	// #ifdef APP-HARMONY
	import "@/uni_modules/harmony-permissions"

	// #endif

	// #ifdef APP

	import {
		getDevicesInfo
	} from "@/uni_modules/mc-device-id"

	// #endif
	plus.screen.lockOrientation('portrait-primary');


	import { ref, reactive, onMounted } from 'vue'
	import { onLoad, onShow } from '@dcloudio/uni-app'
	// import type { UniFormsInstance } from '@dcloudio/uni-ui' // 引入uni-forms类型定义
	import { useMainStore, useUserStore, usePermissionStore } from '@/store';
	import { useSizeStore } from '@/store/shared/fontSize'
	const mainStore = useMainStore();
	const userStore = useUserStore();
	const permissionStore = usePermissionStore();
	const sizeStore = useSizeStore()
	// uni.clearStorageSync()

	const $bluetooth = uni.$utils.initBluetooth();
	uni.$utils.$bluetooth = $bluetooth;

	import useRequestQueue from '@/uni_modules/mc-ui/libs/http/UniversalRequestQueue';
	const { request, requestByUrl, onAllComplete, onError } = useRequestQueue();

	// #ifdef MP-WEIXIN
	uni.login({
		provider: 'weixin', //使用微信登录
		success: function (loginRes) {

		}
	});
	// #endif

	let isHarmonyOS = ref(false);
	// #ifdef APP-HARMONY
	isHarmonyOS.value = true
	// #endif

	// 定义表单数据类型接口
	interface FormData {
		Business_Code : string; // 企业代号
		Business : string | number; // 账套
		UserAccount : string; // 账号
		UserPwd : string; // 密码
		[key : string] : any; // 允许其他属性
	}

	// 获取设备信息
	async function getDeviceInfo() {
		let sysDeviceInfo = reactive<any>({});
		// #ifndef MP-WEIXIN
		Object.assign(sysDeviceInfo, uni.getSystemInfoSync());
		// #endif

		// #ifdef MP-WEIXIN
		Object.assign(sysDeviceInfo, uni.getSystemSetting(), uni.getWindowInfo(), uni.getDeviceInfo(), uni.getAppAuthorizeSetting(), uni.getAppBaseInfo());
		// #endif
		uni.setStorageSync('safeAreaBottom', sysDeviceInfo.safeAreaInsets?.bottom)
		// #ifdef APP-HARMONY



		// #endif

		// #ifndef APP-HARMONY
		// #ifdef APP

		Object.assign(sysDeviceInfo, {
			deviceId: getDevicesInfo().DEVICEID
		})
		// #endif
		// #endif

		// #ifdef MP-WEIXIN

		Object.assign(sysDeviceInfo, {
			deviceId: '0c3kWX100c8i1V19c1100DUMiO3kWX1J'
		})
		// #endif

		mainStore.systemConfig.sysDeviceInfo = sysDeviceInfo;
		uni.setStorageSync("sysDeviceInfo", JSON.stringify(sysDeviceInfo));
		const loginIP = mainStore.appConfigInfo.LoginIP;

		request({
			config: {
				baseURL: `http://${loginIP}/Frame/SqlData?cmdname=`,
			},
			url: 'getScanDeviceInfo',
			method: 'POST',
			data: { DeviceModel: sysDeviceInfo.deviceModel },
			success(ret : any) {

				if (ret.status == 200 && ret.data.ds.length) {
					Object.assign(sysDeviceInfo, ret.data.ds[0]);
					mainStore.systemConfig.sysDeviceInfo = sysDeviceInfo;
					// 缓存用于处理扫码逻辑判断
					uni.setStorageSync("sysDeviceInfo", JSON.stringify(sysDeviceInfo));
				}

			}
		});
	}
	getDeviceInfo();

	// 表单内容
	const formData = reactive<FormData>({
		Business_Code: '',
		Business: '',
		UserAccount: '',
		UserPwd: '',
	});

	// 获取表单组件实例（指定UniFormsInstance类型）
	// 定义uni-forms组件的ref类型
	interface UniFormsInstance {
		validate : (callback ?: (isValid : boolean) => void) => Promise<boolean>
		resetFields : () => void
		setRules : any
	}
	const baseFormRef = ref<UniFormsInstance | any>(null);

	// 定义表单验证规则
	const rules = ref<any>({
		Business_Code: {
			type: 'string',
			required: true,
			message: '请输入企业代号',
			trigger: ['blur', 'change']
		},
		Business: {
			type: 'string',
			required: true,
			message: '请选择账套',
			trigger: ['change']
		},
		UserAccount: {
			type: 'string',
			required: true,
			message: '请输入账号',
			trigger: ['blur', 'change']
		},
		UserPwd: {
			type: 'string',
			required: true,
			message: '请输入密码',
			trigger: ['blur', 'change']
		},
	});

	// 企业代号失焦处理
	function GetBusiness(target : any) {
		const value = target;
		// const value = target.detail.value;

		// 快速检查全零或空值
		if (!value || /^0+$/.test(value)) {
			formData.Business = '';
			formData.BusinessName = '';
			BusinessList.value = [];
			return;
		};

		const loginIP = mainStore.appConfigInfo.LoginIP;

		if (!loginIP) {
			console.error('登录IP未配置');
			return;
		}

		request({
			config: {
				baseURL: `http://${loginIP}/Frame/SqlData?cmdname=`,
			},
			url: 'AP_GetAccountByEnterNo',
			method: 'POST',
			data: { EnterNo: value },
			success(ret : any) {
				if (ret.status === 200) {
					const { ds } = ret.data;
					BusinessList.value = ds.map((item : any) => {
						return {
							...item,
							text: item.AccountName,
							value: item.AccountID
						}
					})

					if (BusinessList.value.length > 0) {
						// 默认选中第一项（优化类型处理）
						let targetItem = reactive(BusinessList.value[0]);
						const currentBusiness = formData.Business;
						if (currentBusiness) {
							// 优先匹配当前选择的企业
							for (let i = 0; i < ds.length; i++) {
								if (ds[i].AccountID === currentBusiness) {
									// targetItem = ds[i];
									Object.assign(targetItem, ds[i])
									break;
								}
							}
						}
						formData.Business = targetItem.AccountID;
						formData.BusinessName = targetItem.AccountName;
						changeSelectByIP(targetItem.ServiceIP);
					} else {
						formData.Business = '';
						formData.BusinessName = '';
					}
				} else {
					formData.Business = '';
					formData.BusinessName = '';
					BusinessList.value = [];
				}
			}
		});
	}

	// 更新IP配置
	function changeSelectByIP(serverIP : string) {
		// 更新pinia数据,存储目的是用于请求中获取
		uni.setStorageSync('serverIP', serverIP);
		mainStore.appConfigInfo.serverIP = serverIP;

		let TheIP = 'http://';
		const TheIndex = serverIP.indexOf(':443');
		if (TheIndex !== -1) {
			TheIP = 'https://';
		}
		uni.setStorageSync('IPAgreement', TheIP);
		mainStore.appConfigInfo.IPAgreement = TheIP;
	}

	// 账套列表类型定义
	interface BusinessItem {
		AccountID : string | number;
		AccountName : string;
		ServiceIP : string;
		[key : string] : any; // 允许其他属性
	}
	const BusinessList = ref<BusinessItem[]>([]);

	// 切换账套
	function SelectBusiness(ID : string | number) {
		const FilterData = BusinessList.value.filter(item => item.AccountID === ID);
		if (FilterData.length > 0) {
			changeSelectByIP(FilterData[0].ServiceIP);
		}
	}

	// 记住密码相关
	let Remember = ref(false);
	let RemberCheck = ref<any>([]);
	function checkboxChange(target : any) {
		RemberCheck.value = target;
		Remember.value = !!target.length;
	}

	// 打开用户协议/隐私政策
	// 打开用户协议、隐私政策
	function openWebInBrowser(type : number) {
		// 获取网页URL
		let url = '';
		let title = "";
		switch (type) {
			case 1: // 用户协议
				url = 'https://api.hzyc.org.cn/download/html/汇创云平台用户协议.html';
				title = "汇创云平台用户协议";
				break;
			case 2: // 隐私政策
				url = 'https://api.hzyc.org.cn/download/html/汇创云平台隐私政策.html';
				title = "汇创云平台隐私政策";
				break;
			default:
				return;
		}

		// #ifdef APP-PLUS
		// 传统APP平台（非鸿蒙）
		try {
			if (plus.runtime.openWeb) {
				plus.runtime.openWeb(url);
			} else if (plus.runtime.openURL) {
				plus.runtime.openURL(url);
			} else {
				console.error('不支持的网页打开方式');
			}
		} catch (e) {
			console.error('打开网页失败:', e);
		}
		// #endif

		// #ifdef MP-WEIXIN || APP-HARMONY
		uni.$utils.navigateToWebView({
			url: url,
			title: title,
			navBgColor: '#51d0d0',
			navTextColor: '#ffffff'
		});
		// #endif


	};


	// 注册按钮
	function togetherBtn(type : string) {

	}

	// 登录配置
	interface LoginConfig {
		isLoading : boolean;
		showMLoading : boolean;
		loadingText : string;
		InterTime : number | null;
		isLoggingIn : boolean;
		listenFun : any;
	}
	let loginConfig = reactive<LoginConfig>({
		isLoading: false,
		showMLoading: false,
		loadingText: "正在渲染",
		InterTime: null,
		isLoggingIn: false,
		listenFun: null,
	});

	// 登录逻辑（核心修改：通过表单实例进行验证）
	async function LoginApp() {


		// 验证表单实例是否存在
		if (!baseFormRef.value) {
			console.error('表单实例未获取到');
			return;
		}
		baseFormRef.value?.validate().then(async (res : any) => {

			loginConfig.showMLoading = true;
			loginConfig.loadingText = "正在校验";

			try {
				await baseFormRef.value.validate();

				loginConfig.loadingText = "表单验证通过";
				loginConfig.isLoading = true;

				let param = {
					P_Name: formData.UserAccount,
					P_Password: formData.UserPwd,
				}

				request({
					config: {
						baseURL: mainStore.appConfigInfo.IPAgreement + mainStore.appConfigInfo.serverIP + "/Frame/ST1_SY/Handler.aspx?cmd="
					},
					url: 'applogin',
					method: 'POST',
					data: param,
					success(ret : any) {
						if (ret.status == 200 && ret.data.ds[0].status != 500) {
							// 登录成功
							// 根据帐套ID获取帐套名称
							let findAccountDame : any = BusinessList.value.find(item => item.AccountID == formData.Business)

							let UserInfo = reactive(ret.data.ds[0]);
							UserInfo.Business_Code = formData.Business_Code;
							UserInfo.Business = formData.Business;
							UserInfo.BusinessName = findAccountDame.AccountName;
							UserInfo.UserAccount = formData.UserAccount;
							UserInfo.UserPwd = formData.UserPwd;



							// 是否记住密码
							if (Remember) {
								UserInfo.Remember = Remember;
								// 开启自动登录
								uni.setStorageSync('Automatic_Login', true)
							}

							// userStore.UserInfo = UserInfo;
							userStore.UserInfo = UserInfo;
							// 存储目的是用于请求中获取数据
							uni.setStorageSync("UserInfo", JSON.stringify(UserInfo));
							loginConfig.loadingText = "正在加载登录信息";

							setTimeout(() => {
								loginConfig.isLoading = false;
								// loginConfig.showMLoading = false;


								// 查看当前登录账套授权信息
								searchApply()
							}, 500)

						} else {
							loginConfig.isLoading = false;
							loginConfig.showMLoading = false;
							uni.showToast({
								title: ret.data.ds[0].msg,
								icon: 'none'
							})
						}

					}
				});

			} catch (errors) {
				// 验证失败


				loginConfig.isLoading = false;
				loginConfig.showMLoading = false;
				uni.showToast({
					title: "请完善表单",
					icon: 'none'
				})
			}

		}).catch((error : any) => {

			loginConfig.isLoading = false;
			loginConfig.showMLoading = false;
			uni.$utils.msg("请完善表单信息！")
		});
	}

	// 查看授权信息
	function searchApply() {

		let param = {
			machineId: mainStore.systemConfig.sysDeviceInfo.deviceId,
		}
		loginConfig.loadingText = "正在校验授权信息";

		request({
			config: {
			},
			url: 'searchapply',
			method: 'POST',
			data: param,
			success: async (ret : any) => {

				if (ret.status == 200) {
					// 查看授权信息完毕后，判定当前登录成功
					mainStore.systemConfig.isLogin = true;
					loginConfig.isLoading = false;

					if (ret.data.ds.length) {
						let Authorization_Info = reactive(ret.data.ds[0]);
						Authorization_Info['Authorization'] = true;
						mainStore.appConfigInfo.Authorization_Info = Authorization_Info;
						// uni.setStorageSync("Authorization_Info", JSON.stringify(Authorization_Info));

						// 通知调取
						// uni.$emit("updateApp", {
						// 	from: 'login'
						// })
						// loginConfig.loadingText = "设备已授权，准备跳转";

						// 获取已开通套餐数据
						loginConfig.loadingText = "正在获取已开通数据";
						await permissionStore.getAppComboInfoByAccountID({ request });


						console.log(permissionStore.activeModule);

						// 预加载模块数据
						if (permissionStore.activeModule) {



							let findModule = permissionStore.appModules.find((item : { ModuleID : number }) => item.ModuleID == permissionStore.activeModule.ModuleID)
							if (uni.$utils.isEmpty(findModule)) {

								loginConfig.showMLoading = false;
								permissionStore.activeModule = null;
								// return
							} else {
								// 小程序需要设定好对应模块的选中模块数据
								permissionStore.activeModule = findModule;

								let str = permissionStore.activeModule;

								// 根据模块获取对应数据
								if (!uni.$utils.isEmpty(permissionStore.activeModule)) {
									let module = str; // 上次选中APP模块
									// initModule(module);

									const ret = await permissionStore.getAPPModulePages({ request, module }) as any;

									if (ret.status == 200) {

									}
								}
							}


						};

						await getSelectFCJType();

						uni.redirectTo({
							url: "/st_pages/index/index" + '?index=' + 0,
							success() {
								loginConfig.showMLoading = false;
							}
						});


					} else {
						loginConfig.loadingText = "设备未授权，准备前往授权";
						// uni.removeStorageSync('Authorization_Info');
						mainStore.appConfigInfo.Authorization_Info = {};
						mainStore.systemConfig.msgConfig.msgNum = 0;
						uni.redirectTo({
							url: "/st_pages/mine/setting/onlyIdentity" + "?backBtn=1",
							success() {
								loginConfig.showMLoading = false;
							}
						});
					}
				} else {
					loginConfig.loadingText = "授权查询失败，请重新登录";

					setTimeout(() => {
						loginConfig.showMLoading = false;
					}, 300)
				}
			}
		});
	}


	const getSelectFCJType = async () => { // 查询公司报工类型
		try {

			await request({
				config: {
				},
				url: 'SelectFCJType',
				method: 'POST',
				data: {},
				success: (ret : any) => {
					console.log(ret);
					ticketStore.FCJType = ret.data.ds[0]['FCJType']
				},
				fail(err : any) {
					console.log(err);
				}
			});

		} catch (e) {
			//TODO handle the exception
		}
	}



	onAllComplete(() => {

		// loginConfig.showMLoading = false;
	});

	// 监听请求错误
	onError((error : any) => {
		console.error('请求错误:', error);
		loginConfig.isLoading = false;
		loginConfig.showMLoading = false;
	});


	// 启动定时器登录（增加登录锁）
	function startInterval() {
		if (loginConfig.InterTime !== null) return;

		loginConfig.InterTime = setInterval(() => {
			attemptAutoLogin();
		}, 500);

	}

	// 停止定时器
	function stopInterval() {
		if (loginConfig.InterTime !== null) {
			clearInterval(loginConfig.InterTime);
			loginConfig.InterTime = null;
		}
	}

	// 注册网络监听器（优化版）
	function registerNetworkListener() {
		if (loginConfig.listenFun !== null) return; // 已注册则不重复监听

		loginConfig.listenFun = function (networkRes : any) {
			if (networkRes.isConnected) {
				startInterval();
				removeNetworkListener(); // 一旦触发就移除
			}
		};

		uni.onNetworkStatusChange(loginConfig.listenFun);
	};

	// 正确解绑网络监听器
	function removeNetworkListener() {
		if (loginConfig.listenFun) {
			uni.offNetworkStatusChange(loginConfig.listenFun); // 正确解绑
			loginConfig.listenFun = null;
		}
	}


	// 自动登录逻辑（增加锁防止重复登录）
	async function attemptAutoLogin() {
		if (loginConfig.isLoggingIn || uni.$utils.isEmpty(formData.Business)) return;

		loginConfig.isLoggingIn = true;
		try {
			await LoginApp(); // 如果是同步函数可移除 await
			stopInterval();
		} catch (err) {
			console.warn("自动登录失败:", err);
		} finally {
			loginConfig.isLoggingIn = false;
		}
	}

	type NetworkType = 'wifi' | '2g' | '3g' | '4g' | '5g' | 'none' | 'unknown';
	async function checkNetworkAndSetup() {
		const result = await uni.getNetworkType();

		const { networkType } = result as { networkType : NetworkType };
		if (networkType !== 'none') {
			// 已联网，立即启动定时器
			startInterval();
		} else {
			// 未联网，注册监听
			registerNetworkListener();
		}
	}

	onLoad(() => {
		uni.setStorageSync('Allow_Restart', '1');
		if (uni.$utils.isEmpty(uni.getStorageSync('Automatic_Login'))) {
			// uni.removeStorageSync('ActiveModule');
			// uni.removeStorageSync('moduleInfoAll');
			// uni.removeStorageSync('moduleTabbar');

			permissionStore.activeModule = null;
			// permissionStore.activeModuleID = null;
			permissionStore.moduleInfoAll = [];
			permissionStore.moduleTabbar = [];

		};

		if (!uni.$utils.isEmpty(userStore.UserInfo)) {
			const {
				Business_Code,
				Business,
				UserAccount,
				// Remember,
				UserPwd
			} = userStore.UserInfo || {};


			Object.assign(formData, {
				...formData,
				Business_Code,
				Business,
				UserAccount
			})


			GetBusiness(Business_Code);
			if (userStore.UserInfo.Remember) {
				formData.UserPwd = UserPwd;
				Remember.value = true;
				RemberCheck.value = ['记住密码'];


				// 开启自动登录程序
				if (uni.getStorageSync('Automatic_Login')) {
					checkNetworkAndSetup()
				}
			} else {
				formData.UserPwd = "";
				Remember.value = false;
				RemberCheck.value = [];
			}
		}

	});

	// 组件挂载完成后确认表单实例
	onMounted(() => {
		// #ifdef MP-WEIXIN
		baseFormRef.value.setRules(rules.value)
		// #endif
	});
</script>


<style lang="scss" scoped>
	/* ===== 全局变量 ===== */
	$primary-color: #51d0d0;
	$text-muted: #a6a6a6;
	$input-border: #e6e8ec;
	$checkbox-border: #d1d1d1;

	/* ===== 通用布局类 ===== */
	.flex-row {
		display: flex;
		flex-direction: row;
		align-items: center;
	}

	.flex-column {
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.flex-center {
		display: flex;
		justify-content: center;
		align-items: center;
	}

	/* ===== 页面容器 ===== */
	.page_content {
		display: flex;
		flex-direction: column;
		align-items: center;
		background-color: #fff;
		min-height: 100vh;
		/* 页面满屏，底部文字自适应 */

		/* ===== Logo 区域 ===== */
		.LogoBox {
			height: 26vh;
			width: 100%;
			display: flex;
			justify-content: center;
			align-items: flex-end;

			.Logo {
				@extend .flex-row;
				align-items: center;

				.img {
					border-radius: 12rpx;
					overflow: hidden;
					filter: drop-shadow(4px 5px 2px rgba(112, 112, 112, 0.2));
				}

				.text {
					margin-left: 20rpx;
					font-size: 64rpx;
					font-weight: 600;
					color: #333;
					letter-spacing: 2px;
					text-shadow: 2px 2px 3px rgba(0, 0, 0, 0.1);
				}
			}
		}

		/* ===== 表单区域 ===== */
		.FormBox {
			width: 100%;
			margin-top: 50px;
			min-height: 200px;

			:deep(.u-form) {
				width: 90% !important;
				margin: 0 auto !important;
			}

			/* 统一选择器样式 */
			:deep(.uni-select),
			:deep(.uni-select__selector-item),
			:deep(.uni-select__input-placeholder),
			:deep(.uni-select__selector-empty) {
				font-size: 28rpx !important;
			}

			:deep(.uni-select) {
				border-bottom: 1px solid $input-border !important;
			}

			:deep(.uni-select__selector) {
				padding: 8rpx 0 !important;
			}

			:deep(.uni-select__selector-item) {
				padding: 10rpx 20rpx !important;
			}

			/* 表单行统一布局 */
			.form-row {
				@extend .flex-row;
				width: 100%;
			}

			/* 图标与输入框间距 */
			.icon-input {
				margin-left: 10rpx;
				flex: 1;
			}
		}

		/* ===== 按钮区域 ===== */
		.BtnBox {
			width: 100%;
			@extend .flex-center;

			.LoginBtn {
				background-color: $primary-color;
				display: flex;
				justify-content: center;
				align-items: center;
				width: 90%;
				margin: 0 auto;
				border-radius: 8rpx;

				.Text {
					margin-left: 10px;
					color: #fff;
					font-size: 30rpx;
				}

				uni-button:after {
					border: none !important;
				}
			}
		}

		/* ===== 复选框样式 ===== */
		.uni-checkbox-input {
			border: 2px solid $checkbox-border !important;
		}

		.uni-checkbox-input-checked {
			background: $primary-color;
			color: #fff !important;
			border-color: $primary-color !important;
		}

		/* ===== 链接文本 ===== */
		.link-text {
			color: $primary-color;
			margin-left: 10rpx;
			font-size: 28rpx;
		}

		/* ===== 底部文字 ===== */
		.BottomText {
			margin-top: auto;
			/* 保持底部 */
			width: 100%;
			text-align: center;
			color: $text-muted;
			font-size: 12px;
			padding-bottom: 20px;
		}
	}
</style>